﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DB2Provider;
//using PiLink;

namespace Bussiness
{
    public class PIModel
    {
        /// <summary>
        /// 测点名
        /// </summary>
        public string TagName { get; set; }
        /// <summary>
        /// 当前值
        /// </summary>
        public double CurrentValue { get; set; }
        /// <summary>
        /// 历史值
        /// </summary>
        public double HistoryValue { get; set; }
        /// <summary>
        /// 均值
        /// </summary>
        public double AvgeValue { get; set; }
        /// <summary>
        /// 最小值
        /// </summary>
        public double MinValue { get; set; }
        /// <summary>
        /// 最大值
        /// </summary>
        public double MaxValue { get; set; }
        /// <summary>
        /// 标值
        /// </summary>
        public double MeanValue { get; set; }
        /// <summary>
        /// PI时间
        /// </summary>
        public string PITime { get; set; }
        /// <summary>
        /// PI连接状态
        /// </summary>
        public int State = -1;
        /// <summary>
        /// 获取当前测点值
        /// </summary>
        /// <param name="tagName">测点名</param>
        /// <param name="PIDeclare">PI服务连接对象</param>
        /// <returns></returns>
        //public double GetCurrentValue(string tagName, PiLink.declare PIDeclare)
        //{
        //    object curValue = null;
        //    string bValue = null;
        //    object bSize = null;
        //    object iStat = null;
        //    object flags = null;
        //    string time = null;

        //    State = PIDeclare.GetCurValue(ref tagName, ref curValue, ref bValue, ref bSize, ref iStat, ref flags, ref time);
        //    if (State == 0)
        //        return Convert.ToDouble(curValue);
        //    else
        //        return 0;
        //}
        /// <summary>
        /// 返回测点历史值
        /// </summary>
        /// <param name="tagName">测点名</param>
        /// <param name="hisTime">历史时间,格式：MM-DD-YYYY HH:MM:SS</param>
        /// <param name="PIDeclare">PI服务连接对象</param>
        /// <returns></returns>
        //public double GetHistory(string tagName, string hisTime, PiLink.declare PIDeclare)
        //{
        //    object hisValue = null;
        //    object bValue = null;
        //    object bSize = null;
        //    object iStat = null;
        //    object flags = null;

        //    State = PIDeclare.GetHistValue(ref tagName, ref hisValue, ref bValue, ref bSize, ref iStat, ref flags, ref hisTime);
        //    if (State == 0)
        //        return Convert.ToDouble(hisValue);
        //    else
        //        return 0;
        //}
        /// <summary>
        /// 插入测点值
        /// </summary>
        /// <param name="tagName">测点名</param>
        /// <param name="insertValue">值</param>
        /// <param name="PIDeclare">PI服务连接对象</param>
        /// <returns></returns>
        //public int InsertValue(string tagName, double insertValue, PiLink.declare PIDeclare)
        //{
        //    object objValue = insertValue as object;
        //    return PIDeclare.SetCurValue(ref tagName, ref objValue);
        //}
        /// <summary>
        /// 修改测点值
        /// </summary>
        /// <param name="tagName">测点名</param>
        /// <param name="editValue">修改测点值</param>
        /// <param name="hisTime">修改时间,格式：MM-DD-YYYY HH:MM:SS</param>
        /// <param name="PIDeclare">PI服务连接对象</param>
        /// <returns></returns>
        //public int EditValue(string tagName, double editValue, string hisTime, PiLink.declare PIDeclare)
        //{
        //    object objValue = editValue as object;
        //    return PIDeclare.SetHistValue(ref tagName, ref objValue, ref hisTime);
        //}
        /// <summary>
        /// 返回测点最大值
        /// </summary>
        /// <param name="tagName">测点名</param>
        /// <param name="startTime">起始时间,格式：MM-DD-YYYY HH:MM:SS</param>
        /// <param name="endTime">结束时间,格式：MM-DD-YYYY HH:MM:SS</param>
        /// <param name="PIDeclare">PI服务连接对象</param>
        /// <returns></returns>
        //public double GetMaxValue(string tagName, string startTime, string endTime, PiLink.declare PIDeclare)
        //{
        //    object rval = null;
        //    State = PIDeclare.GetMaxValue(ref tagName, ref startTime, ref endTime, ref rval);
        //    if (State == 0)
        //        return Convert.ToDouble(rval);
        //    else
        //        return 0;
        //}

    }
}